//
//  ViewController.m
//  scrollview2
//
//  Created by student on 16/2/29.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"
#import "ImageScrollView.h"
#import "DSFImageScrollView.h"
@interface ViewController ()<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIPageControl *pagecontroller;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIImageView *image1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 400, 140)];
    image1.image=[UIImage imageNamed:@"1"];
    UIImageView *image2=[[UIImageView alloc]initWithFrame:CGRectMake(400, 0, 400, 140)];
     image2.image=[UIImage imageNamed:@"2"];
    UIImageView *image3=[[UIImageView alloc]initWithFrame:CGRectMake(400*2, 0, 400, 140)];
     image3.image=[UIImage imageNamed:@"3"];
    UIImageView *image4=[[UIImageView alloc]initWithFrame:CGRectMake(400*3, 0, 400, 140)];
     image4.image=[UIImage imageNamed:@"4"];
    UIImageView *image5=[[UIImageView alloc]initWithFrame:CGRectMake(400*4, 0, 400, 140)];
     image5.image=[UIImage imageNamed:@"5"];
    UIImageView *image6=[[UIImageView alloc]initWithFrame:CGRectMake(400*5, 0, 400, 140)];
     image6.image=[UIImage imageNamed:@"6"];
    UIScrollView *scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 20, 400, 140)];
    scrollview.contentSize=CGSizeMake(400*6,0);
    [scrollview addSubview:image1];
    [scrollview addSubview:image2];
    [scrollview addSubview:image3];
    [scrollview addSubview:image4];
    [scrollview addSubview:image5];
    [scrollview addSubview:image6];
    [self.view addSubview:scrollview];
    scrollview.bounces=YES;
    scrollview.pagingEnabled=YES;
    scrollview.delegate=self;
    self.pagecontroller.numberOfPages=6;
    self.pagecontroller.currentPage=0;
    self.pagecontroller.pageIndicatorTintColor=[UIColor redColor];
    self.pagecontroller.currentPageIndicatorTintColor=[UIColor yellowColor];
    [self.view addSubview:self.pagecontroller];
    
    
    ImageScrollView *myscrollview=[[ImageScrollView alloc]initWithFrame:CGRectMake(0, 200, 400, 140)];
    myscrollview.imagenames=@[@"1",@"2",@"3",@"4"];
    myscrollview.curcolor=[UIColor blueColor];
    myscrollview.othercolor=[UIColor greenColor];
    [self.view addSubview:myscrollview];
    
    
    DSFImageScrollView *myscrollview2=[DSFImageScrollView imagescrollview];
    myscrollview2.imagenames=@[@"1",@"2",@"3",@"4"];
    myscrollview2.frame=CGRectMake(0, 350, 400, 140);
    myscrollview2.curcolor=[UIColor blueColor];
    myscrollview2.othercolor=[UIColor greenColor];
    [self.view addSubview:myscrollview2];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    
    self.pagecontroller.currentPage=scrollView.contentOffset.x/400;
}

@end
